package store.lunangangster.engine.bpmn.parser.handler;

import java.util.Set;
import java.util.stream.Collectors;
import store.lunangangster.bpmn.model.Gateway;
import store.lunangangster.bpmn.model.ParallelGateway;
import store.lunangangster.bpmn.model.SequenceFlow;
import store.lunangangster.engine.bpmn.parser.BpmnParser;
import store.lunangangster.engine.impl.bpmn.behavior.ParallelGatewayBehavior;

public class ParallelGatewayParseHandler extends GatewayParseHandler<ParallelGateway> {

  @Override
  public void handle0(BpmnParser bpmnParser, ParallelGateway parallelGateway) {
    // 同步量
    Set<String> incoming = parallelGateway.getIncoming()
        .stream()
        .map(SequenceFlow::getId)
        .collect(Collectors.toSet());
    parallelGateway.setBehavior(new ParallelGatewayBehavior(incoming));

  }

  @Override
  public Class<? extends Gateway> getType() {
    return ParallelGateway.class;
  }
}
